package com.ticket.web.controller.yanchu;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import com.ticket.system.domain.vo.HallAreaVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ticket.common.annotation.Log;
import com.ticket.common.core.controller.BaseController;
import com.ticket.common.core.domain.AjaxResult;
import com.ticket.common.enums.BusinessType;
import com.ticket.system.domain.YanchuHallArea;
import com.ticket.system.service.IYanchuHallAreaService;
import com.ticket.common.utils.poi.ExcelUtil;
import com.ticket.common.core.page.TableDataInfo;

/**
 * 场馆区域Controller
 * 
 * @date 2023-09-26
 */
@Api(description = "剧场区域管理")
@RestController
@RequestMapping("/system/area")
public class YanchuHallAreaController extends BaseController
{
    @Autowired
    private IYanchuHallAreaService yanchuHallAreaService;

    /**
     * 查询场馆区域列表
     */
    @PreAuthorize("@ss.hasPermi('system:area:list')")
    @GetMapping("/list")
    public TableDataInfo list(YanchuHallArea yanchuHallArea)
    {
        startPage();
        List<YanchuHallArea> list = yanchuHallAreaService.selectYanchuHallAreaList(yanchuHallArea);
        return getDataTable(list);
    }

    @ApiOperation("座位列表")
    @ApiImplicitParam(name = "yanchuHallArea", value = "区域对象", dataType = "yanchuHallArea", dataTypeClass = YanchuHallArea.class)
    @GetMapping("/listArea/forAllUser")
    public TableDataInfo listArea(YanchuHallArea yanchuHallArea)
    {
        List<HallAreaVo> list = yanchuHallAreaService.selectHallAreaVoList(yanchuHallArea);
        return getDataTable(list);
    }

    /**
     * 导出场馆区域列表
     */
    @PreAuthorize("@ss.hasPermi('system:area:export')")
    @Log(title = "场馆区域", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YanchuHallArea yanchuHallArea)
    {
        List<YanchuHallArea> list = yanchuHallAreaService.selectYanchuHallAreaList(yanchuHallArea);
        ExcelUtil<YanchuHallArea> util = new ExcelUtil<YanchuHallArea>(YanchuHallArea.class);
        util.exportExcel(response, list, "场馆区域数据");
    }

    /**
     * 获取场馆区域详细信息
     */
    @GetMapping(value = "/{id}")
    @ApiOperation("获取场馆区域详细信息")
    @ApiImplicitParam(name = "id", value = "区域编码", dataType = "Long", dataTypeClass = Long.class)
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(yanchuHallAreaService.selectYanchuHallAreaById(id));
    }

    /**
     * 新增场馆区域
     */
    @PreAuthorize("@ss.hasPermi('system:area:add')")
    @Log(title = "场馆区域", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody @Valid YanchuHallArea yanchuHallArea)
    {
        return toAjax(yanchuHallAreaService.insertYanchuHallArea(yanchuHallArea));
    }

    /**
     * 修改场馆区域
     */
    @PreAuthorize("@ss.hasPermi('system:area:edit')")
    @Log(title = "场馆区域", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YanchuHallArea yanchuHallArea)
    {
        return toAjax(yanchuHallAreaService.updateYanchuHallArea(yanchuHallArea));
    }

    /**
     * 删除场馆区域
     */
    @PreAuthorize("@ss.hasPermi('system:area:remove')")
    @Log(title = "场馆区域", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yanchuHallAreaService.deleteYanchuHallAreaByIds(ids));
    }
}
